//
//  BlockViewController.swift
//  Swift各种传值
//
//  Created by Bao on 15/12/10.
//  Copyright © 2015年 Microlink. All rights reserved.
//

import UIKit

typealias funcBlock = (string:String) -> (Void)
class BlockViewController: UIViewController {

    

    var block = funcBlock?()
    func initChange(change:funcBlock?){
        block = change
    }
    
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.backgroundColor = UIColor.whiteColor()
        self.title = "Block传值"
        
        let btn:UIButton? = UIButton(type: .Custom)
        btn?.frame = CGRectMake(60, 70, 100, 50)
        btn?.backgroundColor = UIColor.redColor()
        btn?.setTitle("改变title", forState:.Normal)
        btn?.addTarget(self, action: Selector("greetings"), forControlEvents: .TouchUpInside)
        self.view .addSubview(btn!)
        
        // Do any additional setup after loading the view.
    }
    func greetings(){
        
       self.block!(string: "block传值")

    }
  
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
